package com.ax.base.common.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.ws.rs.Path;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ax.base.common.domain.BaseArea;
import com.ax.base.common.domain.Tree;
import com.ax.base.system.domain.MenuDO;

import org.springframework.stereotype.Repository;

@Repository
public interface BaseAreaMapper {
    int deleteByPrimaryKey(Long areaId);

    int insert(BaseArea record);

    int insertSelective(BaseArea record);

    BaseArea selectByPrimaryKey(Long areaId);

    int updateByPrimaryKeySelective(BaseArea record);

    int updateByPrimaryKey(BaseArea record);

    @Select("SELECT " +
            "area_id, area_code, area_name, first_letter, full_name, parent_area_id, area_type," +
            "Registrar_ID, Registrar_Name, create_time, update_time, Flag "+
            "from base_area " +
            "where parent_area_id=0"
    )
    ArrayList<BaseArea> getProvince();

    @Select("<script>"+
    		"SELECT " +
            "area_id, area_code, area_name, first_letter, full_name, parent_area_id, area_type," +
            "Registrar_ID, Registrar_Name, create_time, update_time, Flag "+
            "from base_area " +
            "<where>"+
            "<if test=\"parentId != null\">"+ "and parent_area_id = #{parentId} " + "</if>" + 
            "</where>"+
            "</script>"
    )
    ArrayList<BaseArea> getChild(@Param("parentId") Long parentId);

    @Select("SELECT area_id id,area_name text, parent_area_id parentId FROM base_area")
    List<Tree<MenuDO>> listArea();
    
}